import 'package:flutter/material.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/page/person/collection_business_page.dart';
import 'package:tender_flutter/page/person/collection_tender_page.dart';
import 'package:tender_flutter/style/font_style.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';
import 'package:tender_flutter/widgets/base_appbar.dart';
import 'package:tender_flutter/widgets/round_tab_indicator.dart';

class PersonCollectionPage extends StatefulWidget {
  @override
  _PersonCollectionPageState createState() => _PersonCollectionPageState();
}

class _PersonCollectionPageState extends State<PersonCollectionPage>
    with SingleTickerProviderStateMixin {
  /// 标签
  List<String> _tagTypes;

  /// 列表组件
  List<Widget> _listPages;

  /// 控制器
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    // _tagTypes = ["标讯", "供需", "资质", "企业"];
    _tagTypes = ["标讯", "企业"];
    // _listPages = [
    //   CollectionTenderPage(),
    //   CollectionMarketPage(),
    //   CollectionCertificationPage(),
    //   CollectionBusinessPage()
    // ];
    _listPages = [CollectionTenderPage(), CollectionBusinessPage()];
    _tabController = TabController(
      length: _tagTypes.length,
      vsync: this,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ThemeColors.colorWhite,
      appBar: _initAppBar(),
      body: _initBody(),
    );
  }

  /// 导航
  Widget _initAppBar() {
    return BaseAppBar(
      context,
      Text("我的收藏", style: FonStyle.navTextStyle()),
      backgroundColor: ThemeColors.colorWhite,
    );
  }

  /// 内容体
  Widget _initBody() {
    return Column(
      children: [
        Container(
            height: ScreenAdapter.height(80),
            child: TabBar(
              indicator: RoundUnderlineTabIndicator(
                  borderSide: BorderSide(
                width: 2,
                color: ThemeColors.colorType6,
              )),
              labelStyle: TextStyle(
                fontSize: ScreenAdapter.sp(30),
                fontWeight: FontWeight.w600,
              ),
              unselectedLabelStyle: TextStyle(
                fontSize: ScreenAdapter.sp(30),
                fontWeight: FontWeight.w600,
              ),
              labelColor: ThemeColors.colorType6,
              unselectedLabelColor: ThemeColors.colorType7,
              controller: _tabController,
              tabs: _tagTypes
                  .map((e) => Tab(
                        child: Container(
                          child: Text(e),
                          padding: const EdgeInsets.only(
                            bottom: 0,
                          ),
                        ),
                      ))
                  .toList(),
            )),
        Expanded(
            child: TabBarView(
          controller: _tabController,
          children: _listPages,
        ))
      ],
    );
  }
}
